﻿using Learn.Infraestrutura.Dto.Response;
using System;
using System.Collections.Generic;
using System.Text;

namespace Learn.Service.Instance
{
    /// <summary>
    /// 基础服务类
    /// </summary>
    public abstract class Base_Service
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="result">>0成功,否则失败</param>
        /// <param name="message"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public Api_Result Result(int result, string message = "", object data = null)
        {
            Api_Code code = Api_Code.ok;
            if (result <= 0)
            {
                code = Api_Code.fail;
            }
            string msg = result > 0 ? "操作成功" : "操作失败";
            if (!string.IsNullOrEmpty(message))
            {
                msg = message;
            }
            return new Api_Result()
            {
                    code=code,
                    message=msg,
                    data=data
            };

        }

    }
}
